package org.gavin.sharding.service.impl;

import com.mybatisflex.annotation.UseDataSource;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import org.gavin.sharding.entity.TUser;
import org.gavin.sharding.mapper.TUserMapper;
import org.gavin.sharding.service.TUserService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

import static org.gavin.sharding.entity.table.TUserTableDef.T_USER;

/**
 * 用户表 服务层实现。
 *
 * @author gavin
 * @since 2024-01-31T16:49:03.6472063
 */
@Service
public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser> implements TUserService {
    /**
     * 初始化表
     */
    @Override
    @UseDataSource("sharding-db")
    public void initTable(){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.where(T_USER.CREATE_TIME.eq(LocalDateTime.now()));
        this.mapper.selectListByQuery(queryWrapper);
    }

}
